package com.walleipt;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.Random;

public class Sender {

    public static void main(String[] args) {

        String msg = "hello" ;
        try {
            InetAddress group = InetAddress.getByName("228.5.6.7") ;
            MulticastSocket socket = new MulticastSocket(2222) ;
            socket.joinGroup(group);
            while(true)
            {
                Thread.sleep( 3000 );
                String msg_tmp = msg+"-"+(new Random().nextInt(100)) ;
                DatagramPacket hi = new DatagramPacket(msg_tmp.getBytes(), msg_tmp.length(), group, 2222) ;
                socket.send( hi );
            }

        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
